@extends('default.layouts.adminPublic')
@section('title', '乡镇管理列表')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/admin/indexList.css')}}">
    @endsection
    @section('content')
            <!--导航开始-->
    <div class="crumb_warp">
        <i class="fa fa-home"></i> <a href="{{url('admin/coll_town')}}">首页</a> &raquo; 乡镇管理列表
    </div>
    <!--导航结束-->
    <!--结果集标题与导航组件 开始-->
    <div class="con">
        <div class="conMain">
            <div class="result_wrap">
                <div class="search">
                    <form name="Formso" id="Formso" action="{{url('admin/town_list')}}" method="post">
                        {{csrf_field()}}
                        <span>关键字：</span>
                        <span><input name="keyword" class="keyword" id="keyword" placeholder="请输入地标名称" type="text"></span>
                        <span><input name="submit" class="skeyword" value="搜索" type="submit"></span>
                    </form>
                </div>
                <div class="message" style="margin-top: 15px;">
                    <p><span style="margin-right: 20px; font-size: 15px;"><a href="{{url('admin/coll_town/create')}}"><i class="fa fa-plus"></i>添加乡镇</a></span>
                        <span>目前共查找到<strong>{{$collTown->total()}}</strong>个乡镇！且每页显示地标记录{{$collTown->perPage()}}个。</span>
                    </p>
                </div>
            </div>
            <div class="manage">
                @include('flash::message')
            </div>
            <div class="conInfo">
                <form name="thisForm" id="thisForm" action="" method="post">
                    {{csrf_field()}}
                    <div class="conList" id="conList">
                        <dl class="town">
                            <dt>地标排序</dt>
                            <dd class="town1">地标名称</dd>
                            <dd class="town2">英文名称</dd>
                            <dd class="town3">所属地区</dd>
                            <dd class="town4">地标编码</dd>
                            <dd class="town5">地标经度</dd>
                            <dd class="town6">地标纬度</dd>
                            <dd class="town7">地标操作</dd>
                        </dl>
                        @if($collTown->count() > 0 )
                            @foreach($collTown as  $v)
                                <dl>
                                    <dt class="sort">{{$v->sort}}</dt>
                                    <dd class="town1">{{str_limit($v->name,22)}}</dd>
                                    <dd class="town2">{{str_limit($v->en_name,22)}}</dd>
                                    <dd class="town3">{{str_limit($v->currCity,16)}}</dd>
                                    <dd class="town4">{{$v->cid}}</dd>
                                    <dd class="town5">{{$v->longitude}}</dd>
                                    <dd class="town6">{{$v->latitude}}</dd>
                                    <dd class="town7">
                                        <span><a href="{{url('admin/coll_town/'.$v->id.'/edit')}}">修改乡镇</a></span>
                                        <span><a onclick="delTown($(this),'{{$v->id}}')">删除乡镇</a></span>
                                    </dd>
                                </dl>
                            @endforeach
                        @else
                            <div class="nullcon">对不起！没有地标条件的记录！</div>
                        @endif
                    </div>
                </form>
                <div class="page_list" style="width: 100%; float: left; margin-top:15px;">
                    {!! $collTown->links() !!}
                </div>
            </div>
            <div class="stopper" style="margin-top:10px; border-top: 1px solid #e5e5e5"></div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
@endsection

@section('footerjs')
    @parent
    <script>
        //删除地标
        function delTown(othis,id) {
            layer.confirm('您确定要删除这个乡镇吗？', {
                btn: ['确定', '取消'] //按钮
            }, function () {
                $.post("{{url('admin/coll_town/')}}/" + id, {'_method': 'delete','_token': "{{csrf_token()}}"}, function (data) {
                    if (data.status == 0) {
                        layer.msg(data.msg, {icon: 6,time:1500});
                        othis.parents('dl').remove();
                    } else {
                        layer.msg(data.msg, {icon: 5,time:1500});
                    }
                });
            });
        }
    </script>
@endsection